<template>
    <view class="check-origin-button" v-if='showButton' @click.stop='tapOrigin'>
        <view class="c-flex_column c-align_center c-justify_center">
            <uni-icons type='eye-filled' color="#1893ed" size="30"></uni-icons>
        </view>
        <view class="title">查看原文</view>
    </view>
</template>

<script>
    export default {
        props: {
            unit: {
                type: Object,
                default: function() {
                    return null
                }
            }
        },
        data: function() {
            return {
                show: true,
                extraInfo: null
            }
        },
        computed: {
            showButton: function() {
                return this.show && this.unit
            }
        },
        methods: {
            showCheckOriginButton(show, extraInfo) {
                this.show = show;
                this.extraInfo = extraInfo
            },
            tapOrigin() {
                uni.navigateTo({
                    url: "/pages/unit-detail/subpages/origin/origin",
                    success: (res) => {
                        res.eventChannel.emit("openOriginPage", {
                            unit: this.unit,
                            extraInfo: this.extraInfo
                        })
                    }
                })
            }
        }
    }
</script>

<style lang="scss" scoped>
    .check-origin-button {
        position: fixed;
        right: 0;
        bottom: 180rpx;

        display: flex;
        flex-direction: row;
        align-items: center;

        padding: 15rpx 25rpx;
        height: 80rpx;
        line-height: 80rpx;
        border-top-left-radius: 55rpx;
        border-bottom-left-radius: 55rpx;

        background: #e8f4fd;
        color: #1893ed;

        .title {
            margin-left: 15rpx;
        }
    }
</style>